package leetcode.code0657;

public class Solution {

	char[] d = new char[] { 'U', 'D', 'L', 'R' };

	public boolean judgeCircle(String moves) {
		int x = 0, y = 0;

		for (char c : moves.toCharArray()) {
			if (c == d[0]) {
				y++;
			} else if (c == d[1]) {
				y--;
			} else if (c == d[2]) {
				x--;
			} else {
				x++;
			}
		}
		return x == 0 && y == 0;
	}
}
